import { invoke } from '@tauri-apps/api/tauri'

export interface MetaData {
    size: number
    is_file: boolean
    is_exist: boolean
    is_directory: boolean
}

export async function state(path: string): Promise<MetaData> {
    return await invoke<MetaData>('plugin:file-extra|state', { path })
}

export async function check_exist(path: string): Promise<boolean> {
    return await invoke<boolean>('plugin:file-extra|check_exist', { path })
}

export async function ensure_exist(path: string): Promise<boolean> {
    return await invoke<boolean>('plugin:file-extra|ensure_exist', { path })
}

export async function remove(path: string): Promise<boolean> {
    return await invoke<boolean>('plugin:file-extra|remove', { path })
}

export async function rename(source: string, target: string): Promise<boolean> {
    return await invoke<boolean>('plugin:file-extra|rename', { source, target })
}

export async function copy(source: string, target: string): Promise<number> {
    return await invoke<number>('plugin:file-extra|copy', { source, target })
}

export async function file_md5(path: string): Promise<string> {
    return await invoke<string>('plugin:file-extra|file_md5', { path })
}
